package com.csp.main.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.csp.common.utils.R;
import com.csp.main.entity.UserFans;
import com.csp.main.entity.UserFocus;
import com.csp.main.service.UserFansService;
import com.csp.main.service.UserFocusService;
import com.csp.main.utils.JWTUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 关注 前端控制器
 * </p>
 *
 * @author csp
 * @since 2022-06-09
 */
@RestController
@RequestMapping("/main/user-focus")
public class UserFocusController {

    @Autowired
    private UserFocusService userFocusService;

    @GetMapping("/list")
    public R list(HttpServletRequest request){
        String token = request.getHeader(JWTUtils.USER_LOGIN_TOKEN);
        String userId = JWTUtils.validateToken(token);

        QueryWrapper<UserFocus> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        List<UserFocus> list = userFocusService.list(queryWrapper);
        return R.ok().data("rows",list);
    }

}

